//
//  TravelStrokeTwoTableViewCell.m
//  ToWhere
//
//  Created by dllo on 15/11/18.
//  Copyright © 2015年 www.TE.com. All rights reserved.
//

#import "TravelStrokeTwoTableViewCell.h"
#import "TravelTopicDetailsOneTableViewCell.h"
#import <SDWebImageManager.h>
#import <UIImageView+WebCache.h>

@interface TravelStrokeTwoTableViewCell ()

@property (nonatomic, retain) UILabel *labelEntry_name;

@property (nonatomic, retain) UIImageView *imagePic;

@property (nonatomic, retain) UILabel *labelTips;


@end

@implementation TravelStrokeTwoTableViewCell

-(void)dealloc
{
    [_labelEntry_name release];
    [_imagePic release];
    [_labelTips release];
    [_model release];
    
    [super dealloc];
}
-(instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier
{
    self = [super initWithStyle:style reuseIdentifier:reuseIdentifier];
    
    if (self) {
        [self createView];
    }
    return self;
}

-(void)createView
{
    self.labelEntry_name = [[UILabel alloc]init];
    self.labelEntry_name.textColor = [UIColor blackColor];
    self.labelEntry_name.font = [UIFont systemFontOfSize:17 *kWidth];
    
    [self addSubview:self.labelEntry_name];
    [_labelEntry_name release];
    
    self.imagePic = [[UIImageView alloc]init];
    
    [self addSubview:self.imagePic];
    [_imagePic release];
    
    
    self.labelTips = [[UILabel alloc]init];
    
    self.labelTips.textColor = [UIColor blackColor];
    
    self.labelTips.numberOfLines = 0;
    self.labelTips.font = [UIFont systemFontOfSize:14 *kWidth];
    [self addSubview:self.labelTips];
    [_labelTips release];
    
    
}


-(void)setModel:(TravelStrokeSmallModel *)model
{
    if (_model != model) {
        [_model release];
        _model = [model retain];
    }
    self.labelEntry_name.text = model.entry_name;
    
    [self.imagePic sd_setImageWithURL:[NSURL URLWithString:model.image_url] placeholderImage:[UIImage imageNamed:@"Travel_place"]];
    self.labelTips.text = model.tips;
   
}



-(void)layoutSubviews
{
    [super layoutSubviews];
    
    self.labelEntry_name.frame = CGRectMake(10 *kWidth, 10 *kHeight, self.frame.size.width - 20 *kWidth, 20 *kHeight);
    
    self.imagePic.frame = CGRectMake(10 *kWidth, 40 *kHeight, self.frame.size.width - 20 *kWidth, 160 *kHeight);
    
    self.labelTips.frame = CGRectMake(10 *kWidth, self.imagePic.frame.origin.y +self.imagePic.frame.size.height + 5 *kHeight, self.frame.size.width - 20 *kWidth, [TravelTopicDetailsOneTableViewCell heightOfLabel:self.model.tips andTextFont:[UIFont systemFontOfSize:14 *kWidth] andTextWidth:self.frame.size.width - 20 *kWidth]);
    
    
    
    
    
}


/*
// Only override drawRect: if you perform custom drawing.
// An empty implementation adversely affects performance during animation.
- (void)drawRect:(CGRect)rect {
    // Drawing code
}
*/

@end
